package com.bawan.bwsh.shiro.demo.entity;


import java.io.Serializable;
import java.util.Collection;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * Desc:  ${TODO}
 * Author: zhengcongchun
 * CreateTime: 2014-04-24 17:21
 * LastModifyTime: 2014-04-24 17:21
 * FinalModifier: zhengcongchun
 * Version: 1.0
 */
@Entity
@Table(name = "CMSPermission")
public class Permission implements Serializable {

    private static final long serialVersionUID = -8792590494605747957L;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "pmsid")
    private Long id;

    @Column(length = 50)
    private String name;

    @Column(length = 100)
    private String description;

    @Column(length = 50)
    private String permission;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "parentid")
    private Permission parent;

    @OneToMany(mappedBy = "parent", fetch = FetchType.LAZY, cascade = {CascadeType.ALL})
    private Collection<Permission> children;

    @ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "pmss")
    private Collection<Role> roles;

    //--------------------------------get、set方法-------------------------------------
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getPermission() {
        return permission;
    }

    public void setPermission(String permission) {
        this.permission = permission;
    }

    public Permission getParent() {
        return parent;
    }

    public void setParent(Permission parent) {
        this.parent = parent;
    }

    public Collection<Permission> getChildren() {
        return children;
    }

    public void setChildren(Collection<Permission> children) {
        this.children = children;
    }

    public Collection<Role> getRoles() {
        return roles;
    }

    public void setRoles(Collection<Role> roles) {
        this.roles = roles;
    }
}
